import { NestFactory } from '@nestjs/core'
import { AppModule } from './app.module'
import { NestExpressApplication } from '@nestjs/platform-express'
import { setupSwagger } from './swagger'
import { join } from 'path'
import * as compression from 'compression'

async function bootstrap() {
  const app = await NestFactory.create<NestExpressApplication>(AppModule)
  app.setGlobalPrefix(process.env.PREFIX1)
  app.use(compression())
  app.enableCors()
  app.useStaticAssets(join(__dirname, '..', 'upload'), {
    prefix: '/static',
  })
  setupSwagger(app)
  await app.listen(process.env.PORT, () => {
    console.log(`http://localhost:${process.env.PORT}/api-docs`)
  })
}
bootstrap()
